from app.extensions import db
from datetime import datetime

class SeaTemperature(db.Model):
    __tablename__ = 'sea_temperatures'
    
    id = db.Column(db.Integer, primary_key=True)
    marine_area_id = db.Column(db.Integer, db.ForeignKey('marine_areas.id'))
    latitude = db.Column(db.DECIMAL(10, 6), nullable=False)  # 纬度
    longitude = db.Column(db.DECIMAL(10, 6), nullable=False) # 经度
    temperature = db.Column(db.DECIMAL(5, 2), nullable=False)  # 温度值
    measurement_date = db.Column(db.DateTime, nullable=False)
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    
    marine_area = db.relationship('MarineArea', backref='temperatures') 